'''
Created on Dec 15, 2010

@author: zdb
'''
import sqlite3,urllib
from time import strftime,localtime
#urllib.unquote

'''
c = conn.cursor()
c.execute('select * from stocks order by price')
for row in c:
    print row
'''
def quote_text(str1):
    print 'quote',type(urllib.quote(str1))
    return urllib.quote(str1)
    
        
def unquote_text(str1):
    return urllib.unquote(str1)
        
class DbManger:
    
        
    def insert_word(self,word,meaning):
        conn = sqlite3.connect('trans.db')
        c = conn.cursor() 
        #gmtime,UTC
        time1 = strftime("%a, %d %b %Y %H:%M:%S", localtime())
        str1 = "insert into trans values('" + time1 + "','" + word +"','"+ quote_text(meaning) + "');"
        c.execute(str1) 
        conn.commit()
        c.close()
        
    def GetWordAndMeaning(self):
        conn = sqlite3.connect('trans.db')
        c = conn.cursor() 
        #str1 = "select word,date,meaning from trans order by date;"
        str1 = "select word,date,meaning from trans;"
        c.execute(str1) 
        list1=c.fetchall()
        c.close()
        return list1
        